/**
 * Copyright (c) 2006 RiseSoft Co.,Ltd  
 * $Header$
 */
package net.risesoft.risebi.collection.web.admin;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import net.risesoft.risebi.collection.event.eventobj.EventObject;
import net.risesoft.risebi.collection.event.eventobj.SystemLogEventObj;
import net.risesoft.risebi.collection.formula.file.FileCreator;
import net.risesoft.risebi.collection.formula.generate.AbstractFormulaGenerator;
import net.risesoft.risebi.collection.model.Application;
import net.risesoft.risebi.collection.model.Catalog;
import net.risesoft.risebi.collection.model.Indication;
import net.risesoft.risebi.collection.model.IndicationType;
import net.risesoft.risebi.collection.model.ReportPeriodType;
import net.risesoft.risebi.collection.model.Service;
import net.risesoft.risebi.collection.model.Speciality;
import net.risesoft.risebi.collection.model.SystemLog;
import net.risesoft.risebi.collection.model.Template;
import net.risesoft.risebi.collection.model.TemplateDependence;
import net.risesoft.risebi.collection.model.TemplateFile;
import net.risesoft.risebi.collection.model.User;
import net.risesoft.risebi.collection.service.ApplicationManager;
import net.risesoft.risebi.collection.service.CatalogManager;
import net.risesoft.risebi.collection.service.ComboDefineManager;
import net.risesoft.risebi.collection.service.DbMetaDataManager;
import net.risesoft.risebi.collection.service.DynaBeanManager;
import net.risesoft.risebi.collection.service.FormulaManager;
import net.risesoft.risebi.collection.service.IndicationManager;
import net.risesoft.risebi.collection.service.ReportPeriodTypeManager;
import net.risesoft.risebi.collection.service.SpecialityManager;
import net.risesoft.risebi.collection.service.TemplateDependenceManager;
import net.risesoft.risebi.collection.service.TemplateFileManager;
import net.risesoft.risebi.collection.service.TemplateIndicationManager;
import net.risesoft.risebi.collection.service.TemplateManager;
import net.risesoft.risebi.collection.service.TemplateRangeManager;
import net.risesoft.risebi.collection.service.ValidationManager;
import net.risesoft.risebi.collection.validator.ValidatorManager;
import net.risesoft.risebi.collection.web.BaseAction;
import net.risesoft.risebi.commons.util.ContextUtil;
import net.risesoft.risebi.commons.util.GUID;
import net.risesoft.risebi.commons.util.JSONUtil;
import net.sf.json.JSONObject;

import org.apache.commons.beanutils.LazyDynaBean;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.dao.DataIntegrityViolationException;

/**
 *
 * @author <a href="mailto: dingzhaojun@risesoft.net">丁兆俊</a>
 * @version $Revision$
 *  
 *  This result type takes the following parameters: 

	contentType - the stream mime-type as sent to the web browser (default = text/plain). 
	contentLength - the stream length in bytes (the browser displays a progress bar). 
	contentDisposition - the content disposition header value for specifing the file name (default = inline, values are typically filename="document.pdf". 
	inputName - the name of the InputStream property from the chained action (default = inputStream). 
	bufferSize - the size of the buffer to copy from input to output (default = 1024). 
	These parameters can also be set by exposing a similarly named getter method on your Action. For example, you can provide getContentType() to override that parameter for the current action.
	
	Example: 
	
	 <result name="success" type="stream">
	   <param name="contentType">image/jpeg</param>
	   <param name="inputName">imageStream</param>
	   <param name="contentDisposition">filename="document.pdf"</param>
	   <param name="bufferSize">1024</param>
	 </result>

 */
@Namespace("/admin/TemplateAction")
public class TemplateAction extends BaseAction {


    public TemplateAction()
    {
    }

    public String prepareAdd()
        throws Exception
    {
        return "success";
    }

    public String prepareList()
        throws Exception
    {
        applicationName = ((Application)applicationManager.getObject(Application.class, applicationGuid)).getChineseName();
        String currentServiceGuid = getDefaultService().getGuid();
        List lst = reportPeriodTypeManager.find((new StringBuilder("from ReportPeriodType s where s.service.guid='")).append(currentServiceGuid).append("'").toString());
        jsonReportPeriodType = JSONUtil.getJsonString("include", "guid,name", lst, new String[0]);
        return "success";
    }

    public String prepareTemplateDependence()
        throws Exception
    {
        return "success";
    }

    public String getAvailableTemplates4Dependence()
        throws Exception
    {
        LazyDynaBean ldb = new LazyDynaBean();
        try
        {
            List templateList = new ArrayList();
            List list = templateManager.find((new StringBuilder("from Template t where t.application.guid='")).append(applicationGuid).append("' and t.guid !='").append(node).append("' and t.guid not in( select td.dependence.guid from TemplateDependence td where td.template.guid='").append(node).append("')").toString());
            LazyDynaBean ldb2;
            for(Iterator iterator = list.iterator(); iterator.hasNext(); templateList.add(ldb2))
            {
                Template t = (Template)iterator.next();
                ldb2 = new LazyDynaBean();
                ldb2.set("guid", t.getGuid());
                ldb2.set("code", t.getCode());
                ldb2.set("name", t.getName());
                ldb2.set("tabIndex", t.getTabIndex());
            }

            ldb.set("success", Boolean.valueOf(true));
            ldb.set("reason", "\u83B7\u53D6\u6570\u636E\u6210\u529F!");
            ldb.set("templateList", templateList);
            json = JSONObject.fromObject(ldb).toString();
        }
        catch(Exception e)
        {
            ldb.set("success", Boolean.valueOf(false));
            ldb.set("reason", e.getMessage());
            json = JSONObject.fromObject(ldb).toString();
        }
        return "ajax";
    }

    public String refreshJson()
        throws Exception
    {
        try
        {
            if("jsonTables".equalsIgnoreCase(whichJson))
            {
                ArrayList tables = new ArrayList();
                List lst = dbMetaDataManager.listAllTables(null, null, "DYNA_DATA_%", null);
                tables.addAll(lst);
                lst = dbMetaDataManager.listAllTables(null, null, "DYNA_DATASET_%", null);
                tables.addAll(lst);
                lst = dbMetaDataManager.listAllTables(null, null, "DYNA_CATALOG_%", null);
                tables.addAll(lst);
                json = JSONUtil.getJsonString("include", "table_name", tables, new String[0]);
            } else
            if("jsonTemplates".equalsIgnoreCase(whichJson))
            {
                List lst = templateManager.getTemplatesByApplication(applicationGuid);
                json = JSONUtil.getJsonString("include", "reportPeriodTypeGuid,guid,name,code,description,inner,baseInfo,debug,usage,directReport,tabIndex", lst, new String[0]);
            } else
            if("jsonTemplates4Dependence".equalsIgnoreCase(whichJson))
            {
                List lst = templateDependenceManager.find((new StringBuilder("from TemplateDependence t where t.template.guid='")).append(node).append("' order by t.tabIndex asc").toString());
                ArrayList al = new ArrayList();
                LazyDynaBean ldb;
                for(Iterator iterator = lst.iterator(); iterator.hasNext(); al.add(ldb))
                {
                    TemplateDependence t = (TemplateDependence)iterator.next();
                    ldb = new LazyDynaBean();
                    ldb.set("dependence_guid", t.getDependence_guid());
                    ldb.set("dependence_code", t.getDependence_code());
                    ldb.set("dependence_name", t.getDependence_name());
                    ldb.set("dependence_tabIndex", t.getDependence_tabIndex());
                    ldb.set("isNew", Boolean.valueOf(false));
                }

                json = JSONUtil.getJsonString("include", "dependence_guid,dependence_name,dependence_code,dependence_tabIndex", al, new String[0]);
            } else
            if("jsonTemplateTables".equalsIgnoreCase(whichJson))
            {
                List lst = templateIndicationManager.find((new StringBuilder("select distinct t.tableName from TemplateIndication t where t.template.guid='")).append(node).append("'").toString());
                ArrayList al = new ArrayList();
                LazyDynaBean ldb = null;
                switch(Integer.valueOf(source).intValue())
                {
                default:
                    break;

                case 1: // '\001'
                    ldb = new LazyDynaBean();
                    ldb.set("text", "<<\u521B\u5EFA\u4E3B\u8868>>");
                    ldb.set("menuType", "<<\u521B\u5EFA\u4E3B\u8868>>");
                    ldb.set("cls", "x-btn-text-icon");
                    if(getContextPath().endsWith("/"))
                        ldb.set("icon", (new StringBuilder(String.valueOf(getContextPath()))).append("images/system/fam/add.png").toString());
                    else
                        ldb.set("icon", (new StringBuilder(String.valueOf(getContextPath()))).append("/images/system/fam/add.png").toString());
                    al.add(ldb);
                    for(Iterator iterator4 = lst.iterator(); iterator4.hasNext();)
                    {
                        Object ti = iterator4.next();
                        String tableName = ti.toString();
                        if(tableName.toLowerCase().startsWith("dyna_data_"))
                        {
                            String catalog_guid = (String)catalogManager.getUniqueObject((new StringBuilder("select c.guid from Catalog c where lower(c.tableName)='")).append(tableName.toLowerCase()).append("'").toString());
                            ldb = new LazyDynaBean();
                            ldb.set("catalog_guid", catalog_guid);
                            ldb.set("text", tableName);
                            ldb.set("menuType", "<<\u4E3B\u8868>>");
                            ldb.set("cls", "x-btn-text-icon");
                            if(getContextPath().endsWith("/"))
                                ldb.set("icon", (new StringBuilder(String.valueOf(getContextPath()))).append("images/system/fam/database_table.png").toString());
                            else
                                ldb.set("icon", (new StringBuilder(String.valueOf(getContextPath()))).append("/images/system/fam/database_table.png").toString());
                            al.add(ldb);
                        }
                    }

                    break;

                case 2: // '\002'
                    ldb = new LazyDynaBean();
                    ldb.set("text", "<<\u521B\u5EFA\u7EC6\u8868>>");
                    ldb.set("menuType", "<<\u521B\u5EFA\u7EC6\u8868>>");
                    ldb.set("cls", "x-btn-text-icon");
                    if(getContextPath().endsWith("/"))
                        ldb.set("icon", (new StringBuilder(String.valueOf(getContextPath()))).append("images/system/fam/add.png").toString());
                    else
                        ldb.set("icon", (new StringBuilder(String.valueOf(getContextPath()))).append("/images/system/fam/add.png").toString());
                    al.add(ldb);
                    for(Iterator iterator5 = lst.iterator(); iterator5.hasNext();)
                    {
                        Object ti = iterator5.next();
                        String tableName = ti.toString();
                        if(tableName.toLowerCase().startsWith("dyna_dataset_"))
                        {
                            String catalog_guid = (String)catalogManager.getUniqueObject((new StringBuilder("select c.guid from Catalog c where lower(c.tableName)='")).append(tableName.toLowerCase()).append("'").toString());
                            ldb = new LazyDynaBean();
                            ldb.set("catalog_guid", catalog_guid);
                            ldb.set("text", tableName);
                            ldb.set("menuType", "<<\u7EC6\u8868>>");
                            ldb.set("cls", "x-btn-text-icon");
                            if(getContextPath().endsWith("/"))
                                ldb.set("icon", (new StringBuilder(String.valueOf(getContextPath()))).append("images/system/fam/database_table.png").toString());
                            else
                                ldb.set("icon", (new StringBuilder(String.valueOf(getContextPath()))).append("/images/system/fam/database_table.png").toString());
                            al.add(ldb);
                        }
                    }

                    break;

                case 3: // '\003'
                    ldb = new LazyDynaBean();
                    ldb.set("text", "<<\u521B\u5EFA\u76EE\u5F55>>");
                    ldb.set("menuType", "<<\u521B\u5EFA\u76EE\u5F55>>");
                    ldb.set("cls", "x-btn-text-icon");
                    if(getContextPath().endsWith("/"))
                        ldb.set("icon", (new StringBuilder(String.valueOf(getContextPath()))).append("images/system/fam/add.png").toString());
                    else
                        ldb.set("icon", (new StringBuilder(String.valueOf(getContextPath()))).append("/images/system/fam/add.png").toString());
                    al.add(ldb);
                    for(Iterator iterator6 = lst.iterator(); iterator6.hasNext();)
                    {
                        Object ti = iterator6.next();
                        String tableName = ti.toString();
                        if(tableName.toLowerCase().startsWith("dyna_catalog_"))
                        {
                            String catalog_guid = (String)catalogManager.getUniqueObject((new StringBuilder("select c.guid from Catalog c where lower(c.tableName)='")).append(tableName.toLowerCase()).append("'").toString());
                            ldb = new LazyDynaBean();
                            ldb.set("catalog_guid", catalog_guid);
                            ldb.set("text", tableName);
                            ldb.set("menuType", "<<\u76EE\u5F55>>");
                            ldb.set("cls", "x-btn-text-icon");
                            if(getContextPath().endsWith("/"))
                                ldb.set("icon", (new StringBuilder(String.valueOf(getContextPath()))).append("images/system/fam/table_go.png").toString());
                            else
                                ldb.set("icon", (new StringBuilder(String.valueOf(getContextPath()))).append("/images/system/fam/table_go.png").toString());
                            al.add(ldb);
                        }
                    }

                    break;
                }
                json = JSONUtil.getJsonString(null, null, al, new String[0]);
            } else
            if("jsonTableColumns".equalsIgnoreCase(whichJson))
            {
                List lst = dbMetaDataManager.listAllColumns(this.tableName);
                json = JSONUtil.getJsonString("include", "column_name", lst, new String[0]);
            } else
            if("jsonTableColumns2".equalsIgnoreCase(whichJson))
            {
                List lst = dbMetaDataManager.listAllColumns(this.tableName);
                json = JSONUtil.getJsonString("include", "column_name,data_type,data_length", lst, new String[0]);
            } else
            if("jsonAllIndications".equalsIgnoreCase(whichJson))
            {
                ArrayList al = new ArrayList();
                if(active_node_id == null)
                {
                    List allIndicationTypes = indicationManager.getAllIndicationTypeOrderByTabIndex();
                    LazyDynaBean ldb;
                    for(Iterator iterator1 = allIndicationTypes.iterator(); iterator1.hasNext(); al.add(ldb))
                    {
                        IndicationType it = (IndicationType)iterator1.next();
                        int count = indicationManager.getCount((new StringBuilder("select count(*) from Indication a where a.indicationType.guid='")).append(it.getGuid()).append("'").toString()).intValue();
                        ldb = new LazyDynaBean();
                        ldb.set("guid", it.getGuid());
                        ldb.set("code", it.getCode());
                        ldb.set("tabIndex", it.getTabIndex());
                        ldb.set("parentGuid", "");
                        ldb.set("_node_type", "IndicationType");
                        if(count > 0)
                            ldb.set("_is_leaf", Boolean.valueOf(false));
                        else
                            ldb.set("_is_leaf", Boolean.valueOf(true));
                        ldb.set("fullName", it.getName());
                        ldb.set("shortName", it.getName());
                        ldb.set("typeName", it.getName());
                        ldb.set("measureUnit", "");
                        ldb.set("level", Integer.valueOf(-1));
                        ldb.set("usage", Integer.valueOf(-1));
                        ldb.set("dataType", Integer.valueOf(-1));
                        ldb.set("dataLength", Integer.valueOf(-1));
                        ldb.set("dataPrecision", Integer.valueOf(-1));
                        ldb.set("enabled", Boolean.valueOf(true));
                        ldb.set("virtual", Boolean.valueOf(false));
                    }

                    json = JSONUtil.getJsonString(null, null, al, new String[0]);
                } else
                if("IndicationType".equalsIgnoreCase(active_node_type))
                {
                    List allIndications = indicationManager.getIndicationByTypeOrderByTabIndex(active_node_id);
                    LazyDynaBean ldb;
                    for(Iterator iterator2 = allIndications.iterator(); iterator2.hasNext(); al.add(ldb))
                    {
                        Indication indi = (Indication)iterator2.next();
                        int count = indicationManager.getCount((new StringBuilder("select count(*) from Indication a where a.parentIndication.guid='")).append(indi.getGuid()).append("'").toString()).intValue();
                        ldb = new LazyDynaBean();
                        ldb.set("guid", indi.getGuid());
                        ldb.set("code", indi.getCode());
                        ldb.set("tabIndex", indi.getTabIndex());
                        ldb.set("parentGuid", active_node_id);
                        ldb.set("_node_type", "Indication");
                        if(count > 0)
                            ldb.set("_is_leaf", Boolean.valueOf(false));
                        else
                            ldb.set("_is_leaf", Boolean.valueOf(true));
                        ldb.set("fullName", indi.getFullName());
                        ldb.set("shortName", indi.getShortName());
                        ldb.set("typeName", indi.getTypeName());
                        ldb.set("measureUnit", indi.getMeasureUnit());
                        ldb.set("level", indi.getLevel());
                        ldb.set("usage", indi.getUsage());
                        ldb.set("dataType", indi.getDataType());
                        ldb.set("dataLength", indi.getDataLength());
                        ldb.set("dataPrecision", indi.getDataPrecision());
                        ldb.set("enabled", indi.getEnabled());
                        ldb.set("virtual", indi.getVirtual());
                    }

                    json = JSONUtil.getJsonString(null, null, al, new String[0]);
                } else
                {
                    List allIndications = indicationManager.getIndicationOrderByTabIndex(active_node_id);
                    LazyDynaBean ldb;
                    for(Iterator iterator3 = allIndications.iterator(); iterator3.hasNext(); al.add(ldb))
                    {
                        Indication indi = (Indication)iterator3.next();
                        int count = indicationManager.getCount((new StringBuilder("select count(*) from Indication a where a.parentIndication.guid='")).append(indi.getGuid()).append("'").toString()).intValue();
                        ldb = new LazyDynaBean();
                        ldb.set("guid", indi.getGuid());
                        ldb.set("code", indi.getCode());
                        ldb.set("tabIndex", indi.getTabIndex());
                        ldb.set("parentGuid", indi.getParentGuid());
                        ldb.set("_node_type", "Indication");
                        if(count > 0)
                            ldb.set("_is_leaf", Boolean.valueOf(false));
                        else
                            ldb.set("_is_leaf", Boolean.valueOf(true));
                        ldb.set("fullName", indi.getFullName());
                        ldb.set("shortName", indi.getShortName());
                        ldb.set("typeName", indi.getTypeName());
                        ldb.set("measureUnit", indi.getMeasureUnit());
                        ldb.set("level", indi.getLevel());
                        ldb.set("usage", indi.getUsage());
                        ldb.set("dataType", indi.getDataType());
                        ldb.set("dataLength", indi.getDataLength());
                        ldb.set("dataPrecision", indi.getDataPrecision());
                        ldb.set("enabled", indi.getEnabled());
                        ldb.set("virtual", indi.getVirtual());
                    }

                    json = JSONUtil.getJsonString(null, null, al, new String[0]);
                }
            }
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
        return "ajax";
    }

    public String insertOrUpdate()
        throws Exception
    {
        LazyDynaBean ldb = new LazyDynaBean();
        try
        {
            Template templateList[] = (Template[])JSONUtil.stringToArray(json, Template.class);
            Application a = new Application();
            a.setGuid(node);
            Template atemplate[];
            int j = (atemplate = templateList).length;
            for(int i = 0; i < j; i++)
            {
                Template s = atemplate[i];
                if(s.getGuid() == null || s.getGuid().trim().length() == 0 || s.getGuid().startsWith("NEW"))
                {
                    s.setGuid((new GUID()).toString());
                    s.setApplication(a);
                    templateManager.saveObject(s);
                } else
                {
                    Template old = (Template)templateManager.getObject(Template.class, s.getGuid());
                    old.setCode(s.getCode());
                    old.setDebug(s.getDebug());
                    old.setDescription(s.getDescription());
                    old.setName(s.getName());
                    old.setReportPeriodTypeGuid(s.getReportPeriodTypeGuid());
                    old.setTabIndex(s.getTabIndex());
                    old.setUsage(s.getUsage());
                    old.setInner(s.getInner());
                    old.setBaseInfo(s.getBaseInfo());
                    templateManager.saveObject(old);
                }
            }

            ldb.set("success", Boolean.valueOf(true));
            ldb.set("reason", "\u4FDD\u5B58\u6210\u529F!");
            json = JSONObject.fromObject(ldb).toString();
        }
        catch(Exception e)
        {
            ldb.set("success", Boolean.valueOf(false));
            ldb.set("reason", e.getMessage());
            json = JSONObject.fromObject(ldb).toString();
            e.printStackTrace();
        }
        return "ajax";
    }

    public String prepareEditFormula()
        throws Exception
    {
        return "success";
    }

    public String prepareSelectAlias()
        throws Exception
    {
        return "success";
    }

    public String prepareEditExpression()
        throws Exception
    {
        return "success";
    }

    public String prepareEditAliasName()
        throws Exception
    {
        return "success";
    }

    public String prepareEditToolTip()
        throws Exception
    {
        return "success";
    }

	@Action(value="prepareEditCellProperty",
			results={@Result(name="success", location="/admin/template/editCellProperty.jsp")}
	)
	public String prepareEditCellProperty() throws Exception {
		
		return SUCCESS;
	}

	@Action(value="prepareSelectTable",
			results={@Result(name="success", location="/admin/template/selectTable.jsp")}
	)
	public String prepareSelectTable() throws Exception {
		List<Catalog> list = catalogManager.getTablesByTemplateGuid(node);
		
		this.json = "";
		for(Catalog c : list){
			if(this.json.length()==0){
				this.json = "'" + c.getTableName() + "'";
			}else{
				this.json += ",'" + c.getTableName() + "'";
			}			
		}
		this.json = "[" + this.json + "]";
		
		return SUCCESS;
	}

    public String prepareSelectChineseName()
        throws Exception
    {
        return "success";
    }

    public String prepareSelectColumn()
        throws Exception
    {
        return "success";
    }

    public String prepareSelectIndication()
        throws Exception
    {
        ArrayList indicationAncestors = new ArrayList();
        String guid = ModalDialogFieldValue;
        if(guid != null && guid.length() > 0)
        {
            getIndicationAncestors(indicationAncestors, guid);
            if(indicationAncestors.size() > 0)
            {
                for(int i = 0; i < indicationAncestors.size(); i++)
                    if(ModalDialogFieldValue.trim().length() == 0)
                        ModalDialogFieldValue = (String)indicationAncestors.get(i);
                    else
                        ModalDialogFieldValue = (new StringBuilder(String.valueOf((String)indicationAncestors.get(i)))).append(",").append(ModalDialogFieldValue).toString();

            }
        }
        return "success";
    }

    public void getIndicationAncestors(ArrayList ancestors, String guid)
        throws Exception
    {
        Indication indi = (Indication)indicationManager.getObject(Indication.class, guid);
        if(indi == null)
            return;
        String pId = indi.getParentGuid();
        if(pId == null || pId.trim().length() == 0)
        {
            ancestors.add(indi.getIndicationType().getGuid());
            return;
        } else
        {
            ancestors.add(pId);
            getIndicationAncestors(ancestors, pId);
            return;
        }
    }

    public String prepareSelectCatalog()
        throws Exception
    {
        try
        {
            List lst = catalogManager.getCatalogByType(4);
            json = JSONUtil.getJsonString("include", "guid,code,name,type,enabled,hierarchicalType,tabIndex", lst, new String[0]);
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
        return "success";
    }

    public String prepareEdit()
        throws Exception
    {
        try
        {
            if(template.getGuid() != null && template.getGuid().trim().length() > 0)
            {
                template = (Template)templateManager.getObject(Template.class, template.getGuid());
            } else
            {
                template.setTabIndex(Double.valueOf(1.0D));
                template.setDebug(Boolean.valueOf(false));
                template.setInner(Boolean.valueOf(false));
                template.setUsage(Integer.valueOf(1));
                template.setBaseInfo(Boolean.valueOf(false));
            }
            List rts = reportPeriodTypeManager.getReportPeriodTypeByServiceGuid(getDefaultService().getGuid());
            jsonReportPeriodType = JSONUtil.getJsonString("include", "guid,name", rts, new String[0]);
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
        return "success";
    }

    public String prepareCreateMainTable()
        throws Exception
    {
        template = (Template)templateManager.getObject(Template.class, node);
        return "success";
    }

    public String prepareCreateSubTable()
        throws Exception
    {
        template = (Template)templateManager.getObject(Template.class, node);
        return "success";
    }

    public String prepareTemplateDesigner()
        throws Exception
    {
        try
        {
            template = (Template)templateManager.getObject(Template.class, node);
            try
            {
                TemplateFile tf = template.getTemplateFile();
                if(tf != null)
                {
                    templateFileGuid = tf.getGuid();
                    userDefinedJs = tf.getUserDefinedJs();
                }
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
            if(templateFileGuid == null)
                templateFileGuid = "";
            List tis = template.getTemplateIndications();
            jsonIndication = JSONUtil.getJsonString("exclude", "indication,template", tis, new String[0]);
            List trs = template.getTemplateRanges();
            jsonRange = JSONUtil.getJsonString("exclude", "template", trs, new String[0]);
            List fs = template.getFormulas();
            jsonFormula = JSONUtil.getJsonString("exclude", "template", fs, new String[0]);
            List vs = template.getValidations();
            jsonValidation = JSONUtil.getJsonString("exclude", "template", vs, new String[0]);
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
        return "success";
    }

    public String prepareTemplateManager()
        throws Exception
    {
        try
        {
            template = (Template)templateManager.getObject(Template.class, node);
            try
            {
                TemplateFile tf = template.getTemplateFile();
                if(tf != null)
                {
                    templateFileGuid = tf.getGuid();
                    userDefinedJs = tf.getUserDefinedJs();
                }
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
            if(templateFileGuid == null)
                templateFileGuid = "";
            List tis = template.getTemplateIndications();
            jsonIndication = JSONUtil.getJsonString("exclude", "indication,template", tis, new String[0]);
            List trs = template.getTemplateRanges();
            jsonRange = JSONUtil.getJsonString("exclude", "template", trs, new String[0]);
            List fs = template.getFormulas();
            jsonFormula = JSONUtil.getJsonString("exclude", "template", fs, new String[0]);
            List vs = template.getValidations();
            jsonValidation = JSONUtil.getJsonString("exclude", "template", vs, new String[0]);
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
        return "success";
    }

    public String edit()
        throws Exception
    {
        net.risesoft.risebi.collection.model.User user = getSessionUser();
        boolean isNew = false;
        LazyDynaBean ldb = new LazyDynaBean();
        try
        {
            Template templateOld;
            if(template.getGuid() != null && template.getGuid().trim().length() > 0)
            {
                templateOld = (Template)templateManager.getObject(Template.class, template.getGuid());
            } else
            {
                templateOld = new Template();
                templateOld.setGuid((new GUID()).toString());
                templateOld.setApplication(template.getApplication());
                isNew = true;
            }
            templateOld.setCode(template.getCode());
            templateOld.setName(template.getName());
            templateOld.setDescription(template.getDescription());
            templateOld.setDebug(template.getDebug());
            templateOld.setUsage(template.getUsage());
            templateOld.setDirectReport(template.getDirectReport());
            templateOld.setTabIndex(template.getTabIndex());
            templateOld.setInner(template.getInner());
            templateOld.setBaseInfo(template.getBaseInfo());
            templateOld.setDebug(template.getDebug());
            templateOld.setWorkflowGuid(template.getWorkflowGuid());
            templateOld.setReportPeriodTypeGuid(template.getReportPeriodTypeGuid());
            templateManager.saveObject(templateOld);
            ldb.set("guid", templateOld.getGuid());
            ldb.set("name", templateOld.getName());
            ldb.set("code", templateOld.getCode());
            ldb.set("description", templateOld.getDescription());
            ldb.set("inner", templateOld.getInner());
            ldb.set("debug", templateOld.getDebug());
            ldb.set("usage", templateOld.getUsage());
            ldb.set("directReport", templateOld.getDirectReport());
            ldb.set("baseInfo", templateOld.getBaseInfo());
            ldb.set("reportPeriodTypeGuid", templateOld.getReportPeriodTypeGuid());
            ldb.set("workflowGuid", templateOld.getWorkflowGuid());
            ldb.set("tabIndex", templateOld.getTabIndex());
            SystemLog systemLog = new SystemLog();
            if(isNew)
                systemLog.setOpterateType(Integer.valueOf(2));
            else
                systemLog.setOpterateType(Integer.valueOf(3));
            systemLog.setUser(user);
            Service service = getDefaultService();
            systemLog.setServiceGuid(service.getGuid());
            EventObject systemLogEventObject = new SystemLogEventObj(this);
            Map systemLogMap = new HashMap();
            systemLogMap.put("systemLog", systemLog);
            if(isNew)
                systemLogMap.put("keyName", "templateadd");
            else
                systemLogMap.put("keyName", "templateedit");
            systemLogMap.put("template", templateOld);
            systemLogEventObject.setDataMap(systemLogMap);
            ContextUtil.getAc().publishEvent(systemLogEventObject);
            ldb.set("success", Boolean.valueOf(true));
            ldb.set("reason", "\u4FDD\u5B58\u6A21\u7248\u6210\u529F!");
            json = JSONObject.fromObject(ldb).toString();
        }
        catch(Exception e)
        {
            ldb.set("success", Boolean.valueOf(false));
            ldb.set("reason", e.getMessage());
            json = JSONObject.fromObject(ldb).toString();
        }
        return "ajax";
    }

    public String upload()
        throws Exception
    {
        LazyDynaBean ldb = new LazyDynaBean();
        String err = "";
        try
        {
            templateManager.uploadTemplateFile(node, templateExcelFileName, templateExcel, userDefinedJs, jsonIndication, jsonRange, jsonFormula, jsonValidation, deletedIndicationGuid, deletedRangeGuid, deletedFormulaGuid, deletedValidationGuid);
            ldb.set("success", Boolean.valueOf(true));
            ldb.set("reason", "\u4FDD\u5B58\u6A21\u677F\u6210\u529F!");
            json = JSONObject.fromObject(ldb).toString();
        }
        catch(Exception e)
        {
            err = (new StringBuilder(String.valueOf(err))).append(e.getMessage()).append("\r\n").toString();
            ldb.set("success", Boolean.valueOf(false));
            ldb.set("reason", err);
            json = JSONObject.fromObject(ldb).toString();
        }
        return "ajax";
    }

    public String updateValidation()
        throws Exception
    {
        LazyDynaBean ldb = new LazyDynaBean();
        try
        {
            templateManager.updateValidation(node, userDefinedJs, jsonValidation, deletedValidationGuid);
            ldb.set("success", Boolean.valueOf(true));
            ldb.set("reason", "\u4FDD\u5B58\u6210\u529F!");
            json = JSONObject.fromObject(ldb).toString();
        }
        catch(Exception e)
        {
            ldb.set("success", Boolean.valueOf(false));
            ldb.set("reason", e.getMessage());
            json = JSONObject.fromObject(ldb).toString();
        }
        return "ajax";
    }

    public String updateFormula()
        throws Exception
    {
        LazyDynaBean ldb = new LazyDynaBean();
        try
        {
            templateManager.updateFormula(node, jsonFormula, deletedFormulaGuid);
            ldb.set("success", Boolean.valueOf(true));
            ldb.set("reason", "\u4FDD\u5B58\u6210\u529F!");
            json = JSONObject.fromObject(ldb).toString();
        }
        catch(Exception e)
        {
            ldb.set("success", Boolean.valueOf(false));
            ldb.set("reason", e.getMessage());
            json = JSONObject.fromObject(ldb).toString();
        }
        return "ajax";
    }

    public String updateValidationAndFormula()
        throws Exception
    {
        LazyDynaBean ldb = new LazyDynaBean();
        try
        {
            templateManager.updateValidationAndFormula(node, userDefinedJs, jsonFormula, jsonValidation, deletedFormulaGuid, deletedValidationGuid);
            ldb.set("success", Boolean.valueOf(true));
            ldb.set("reason", "\u4FDD\u5B58\u6210\u529F!");
            json = JSONObject.fromObject(ldb).toString();
        }
        catch(Exception e)
        {
            ldb.set("success", Boolean.valueOf(false));
            ldb.set("reason", e.getMessage());
            e.printStackTrace();
            json = JSONObject.fromObject(ldb).toString();
        }
        return "ajax";
    }

    public String buildFormula()
        throws Exception
    {
        LazyDynaBean ldb = new LazyDynaBean();
        String err = "";
        try
        {
            fileCreator.createFile(node);
            ldb.set("success", Boolean.valueOf(true));
            ldb.set("reason", "\u751F\u6210Formula\u6210\u529F!");
            json = JSONObject.fromObject(ldb).toString();
        }
        catch(Exception e)
        {
            err = (new StringBuilder(String.valueOf(err))).append(e.getMessage()).append("\r\n").toString();
            ldb.set("success", Boolean.valueOf(false));
            ldb.set("reason", err);
            json = JSONObject.fromObject(ldb).toString();
        }
        return "ajax";
    }

    public String validateFormula()
        throws Exception
    {
        LazyDynaBean ldb = new LazyDynaBean();
        String err = "";
        try
        {
            serverFormulaGenerator.validate(node);
            ldb.set("success", Boolean.valueOf(true));
            ldb.set("reason", "\u516C\u5F0F\u6CA1\u6709\u53D1\u73B0\u9519\u8BEF!");
            json = JSONObject.fromObject(ldb).toString();
        }
        catch(Exception e)
        {
            String errorMsg = e.getMessage();
            errorMsg = errorMsg.replaceAll("net.risesoft.risebi.collection.formula.generate.FormulaGenerateException: ", "");
            err = errorMsg;
            ldb.set("success", Boolean.valueOf(false));
            ldb.set("reason", err);
            json = JSONObject.fromObject(ldb).toString();
        }
        return "ajax";
    }

    public String download()
        throws Exception
    {
        ByteArrayInputStream bais = null;
        try
        {
            template = (Template)templateManager.getObject(Template.class, node);
            TemplateFile tf = template.getTemplateFile();
            if(tf == null)
                tf = (TemplateFile)templateFileManager.getObject(TemplateFile.class, templateFileGuid);
            byte b[] = tf.getTemplateFile_Blob();
            bais = new ByteArrayInputStream(b);
            excelInputStream = bais;
            contentLength = b.length;
        }
        catch(Exception e)
        {
            e.printStackTrace();
            return "success";
        }
        return "success";
    }

    public String remove()
        throws Exception
    {
        LazyDynaBean ldb = new LazyDynaBean();
        try
        {
            Template template = (Template)templateManager.getObject(Template.class, node);
            templateManager.executeNativeSql((new StringBuilder("delete from rpt7_usertemplate where template_guid='")).append(node).append("'").toString());
            templateManager.executeNativeSql((new StringBuilder("delete from rpt7_template_validation where template_guid='")).append(node).append("'").toString());
            templateManager.executeNativeSql((new StringBuilder("delete from rpt7_template_range where template_guid='")).append(node).append("'").toString());
            templateManager.executeNativeSql((new StringBuilder("delete from rpt7_template_indication where template_guid='")).append(node).append("'").toString());
            templateManager.executeNativeSql((new StringBuilder("delete from rpt7_template_dependence where template_guid='")).append(node).append("' or Dependence_Template_GUID='").append(node).append("'").toString());
            templateManager.executeNativeSql((new StringBuilder("delete from rpt7_reportperiod_template where template_guid='")).append(node).append("'").toString());
            templateManager.executeNativeSql((new StringBuilder("delete from rpt7_reportinstance where template_guid='")).append(node).append("'").toString());
            templateManager.executeNativeSql((new StringBuilder("delete from rpt7_formula where template_guid='")).append(node).append("'").toString());
            templateManager.executeNativeSql((new StringBuilder("delete from rpt7_errorlog where template_guid='")).append(node).append("'").toString());
            templateManager.executeNativeSql((new StringBuilder("delete from rpt7_catalog where template_guid='")).append(node).append("'").toString());
            templateManager.removeObject(Template.class, node);
            if(template.getTemplateFile() != null)
                templateFileManager.removeObject(TemplateFile.class, template.getTemplateFile().getGuid());
            ldb.set("success", Boolean.valueOf(true));
            ldb.set("reason", "\u5220\u9664\u6210\u529F!");
            json = JSONObject.fromObject(ldb).toString();
        }
        catch(DataIntegrityViolationException e)
        {
            ldb.set("success", Boolean.valueOf(false));
            String err = dynaBeanManager.getDataIntegrityViolationExceptionExplain("rpt7_template", node);
            ldb.set("reason", err);
            json = JSONObject.fromObject(ldb).toString();
        }
        catch(Exception e)
        {
            ldb.set("success", Boolean.valueOf(false));
            ldb.set("reason", e.getMessage());
            json = JSONObject.fromObject(ldb).toString();
            e.printStackTrace();
        }
        return "ajax";
    }

    public String removeTemplateDependence()
        throws Exception
    {
        LazyDynaBean ldb = new LazyDynaBean();
        try
        {
            List list = templateDependenceManager.find((new StringBuilder("from TemplateDependence t where t.template.guid='")).append(node).append("' and t.dependence.guid='").append(source).append("'").toString());
            if(list.size() > 0)
                templateDependenceManager.removeObject(TemplateDependence.class, ((TemplateDependence)list.get(0)).getGuid());
            ldb.set("success", Boolean.valueOf(true));
            ldb.set("reason", "\u5220\u9664\u6210\u529F!");
            json = JSONObject.fromObject(ldb).toString();
        }
        catch(Exception e)
        {
            ldb.set("success", Boolean.valueOf(false));
            ldb.set("reason", e.getMessage());
            json = JSONObject.fromObject(ldb).toString();
            e.printStackTrace();
        }
        return "ajax";
    }

    public String updateTemplateDependence()
        throws Exception
    {
        LazyDynaBean ldb = new LazyDynaBean();
        try
        {
            templateDependenceManager.execute((new StringBuilder("delete from TemplateDependence td where td.template.guid='")).append(node).append("'").toString());
            Template tmp = (Template)templateManager.getObject(Template.class, node);
            String arry1[] = json.split(";");
            String as[];
            int j = (as = arry1).length;
            for(int i = 0; i < j; i++)
            {
                String s = as[i];
                if(s.trim().length() > 0)
                {
                    String arry2[] = s.split(",");
                    TemplateDependence td = new TemplateDependence();
                    td.setGuid((new GUID()).toString(32));
                    td.setTabIndex(Double.valueOf(arry2[1]));
                    td.setTemplate(tmp);
                    Template tmpDepend = (Template)templateManager.getObject(Template.class, arry2[0]);
                    td.setDependence(tmpDepend);
                    templateDependenceManager.saveObject(td);
                }
            }

            ldb.set("success", Boolean.valueOf(true));
            ldb.set("reason", "\u4FDD\u5B58\u6210\u529F!");
            json = JSONObject.fromObject(ldb).toString();
        }
        catch(Exception e)
        {
            ldb.set("success", Boolean.valueOf(false));
            ldb.set("reason", e.getMessage());
            json = JSONObject.fromObject(ldb).toString();
            e.printStackTrace();
        }
        return "ajax";
    }

	@Action(value="buildTemplate")
    public String buildTemplate()
        throws Exception
    {

		LazyDynaBean ldb = new  LazyDynaBean();
		String err = "";
		try{
//			首先判断一下有没有templateFile
			Template template = (Template) templateManager.getObject(Template.class, this.node);
			TemplateFile templateFile = template.getTemplateFile();
			if(templateFile==null){
				ldb.set("success", false);
				ldb.set("reason", "尚未设定好 "+this.node+" 下的模板文件，请先设定模板。");
				this.json = JSONObject.fromObject(ldb).toString();
				
				return "buildTemplate";
			}
			
//			生成表单
			User user = this.getSessionUser();
			String rValue = templateManager.convertHtml(this.node, user);
			err += rValue + "\n\r";
			
//			生成审核公式
			try{
				fileCreator.createFile(this.node);

				err += "审核公式生成成功!\n\r";
			}catch(Exception e){
				err += e.getMessage() + "\r\n";
			}
			
//			生成校验规则
			try {
				//validationManager.generateValidationXml(this.node);
				
				err += "校验规则生成成功!\n\r";
			} catch (Exception e) {
				err += e.getMessage() + "\r\n";
			}
			
			ldb.set("success", true);
			ldb.set("reason", err);
			this.json = JSONObject.fromObject(ldb).toString();
		}catch(Exception e){
			err = err + e.getMessage() + "\r\n";
			
			ldb.set("success", false);
			ldb.set("reason", err);
			this.json = JSONObject.fromObject(ldb).toString();
		}
		
		return AJAX;
	
    }

    public String convertHTML()
    {
        LazyDynaBean ldb = new LazyDynaBean();
        String err = "";
        try
        {
            net.risesoft.risebi.collection.model.User user = getSessionUser();
            String rValue = templateManager.convertHtml(node, user);
            err = (new StringBuilder(String.valueOf(err))).append(rValue).append("\n\r").toString();
            ldb.set("success", Boolean.valueOf(true));
            ldb.set("reason", err);
            json = JSONObject.fromObject(ldb).toString();
        }
        catch(Exception e)
        {
            e.printStackTrace();
            err = (new StringBuilder(String.valueOf(err))).append(e.getMessage()).append("\r\n").toString();
            ldb.set("success", Boolean.valueOf(false));
            ldb.set("reason", err);
            json = JSONObject.fromObject(ldb).toString();
        }
        return "ajax";
    }

    public String getJsonIndication()
    {
        return jsonIndication;
    }

    public void setJsonIndication(String jsonIndication)
    {
        this.jsonIndication = jsonIndication;
    }

    public String getJsonRange()
    {
        return jsonRange;
    }

    public void setJsonRange(String jsonRange)
    {
        this.jsonRange = jsonRange;
    }

    public File getTemplateExcel()
    {
        return templateExcel;
    }

    public void setTemplateExcel(File templateExcel)
    {
        this.templateExcel = templateExcel;
    }

    public String getTemplateExcelFileName()
    {
        return templateExcelFileName;
    }

    public void setTemplateExcelFileName(String templateExcelFileName)
    {
        this.templateExcelFileName = templateExcelFileName;
    }

    public String getTemplateExcelContentType()
    {
        return templateExcelContentType;
    }

    public void setTemplateExcelContentType(String templateExcelContentType)
    {
        this.templateExcelContentType = templateExcelContentType;
    }

    public void setTemplateFileManager(TemplateFileManager templateFileManager)
    {
        this.templateFileManager = templateFileManager;
    }

    public InputStream getExcelInputStream()
    {
        return excelInputStream;
    }

    public long getContentLength()
    {
        return (long)contentLength;
    }

    public void setApplicationManager(ApplicationManager applicationManager)
    {
        this.applicationManager = applicationManager;
    }

    public String getJsonApplication()
    {
        return jsonApplication;
    }

    public void setJsonApplication(String jsonApplication)
    {
        this.jsonApplication = jsonApplication;
    }

    public String getJsonReportPeriodType()
    {
        return jsonReportPeriodType;
    }

    public void setJsonReportPeriodType(String jsonReportPeriodType)
    {
        this.jsonReportPeriodType = jsonReportPeriodType;
    }

    public ReportPeriodTypeManager getReportPeriodTypeManager()
    {
        return reportPeriodTypeManager;
    }

    public void setReportPeriodTypeManager(ReportPeriodTypeManager reportPeriodTypeManager)
    {
        this.reportPeriodTypeManager = reportPeriodTypeManager;
    }

    public String getJsonFormula()
    {
        return jsonFormula;
    }

    public void setJsonFormula(String jsonFormula)
    {
        this.jsonFormula = jsonFormula;
    }

    public FormulaManager getFormulaManager()
    {
        return formulaManager;
    }

    public void setFormulaManager(FormulaManager formulaManager)
    {
        this.formulaManager = formulaManager;
    }

    public static long getSerialVersionUID()
    {
        return -6930208653794376921L;
    }

    public TemplateManager getTemplateManager()
    {
        return templateManager;
    }

    public SpecialityManager getSpecialityManager()
    {
        return specialityManager;
    }

    public TemplateFileManager getTemplateFileManager()
    {
        return templateFileManager;
    }

    public ApplicationManager getApplicationManager()
    {
        return applicationManager;
    }

    public void setExcelInputStream(InputStream excelInputStream)
    {
        this.excelInputStream = excelInputStream;
    }

    public void setContentLength(int contentLength)
    {
        this.contentLength = contentLength;
    }

    public String getDeletedIndicationGuid()
    {
        return deletedIndicationGuid;
    }

    public void setDeletedIndicationGuid(String deletedIndicationGuid)
    {
        this.deletedIndicationGuid = deletedIndicationGuid;
    }

    public String getDeletedRangeGuid()
    {
        return deletedRangeGuid;
    }

    public void setDeletedRangeGuid(String deletedRangeGuid)
    {
        this.deletedRangeGuid = deletedRangeGuid;
    }

    public TemplateIndicationManager getTemplateIndicationManager()
    {
        return templateIndicationManager;
    }

    public void setTemplateIndicationManager(TemplateIndicationManager templateIndicationManager)
    {
        this.templateIndicationManager = templateIndicationManager;
    }

    public TemplateRangeManager getTemplateRangeManager()
    {
        return templateRangeManager;
    }

    public void setTemplateRangeManager(TemplateRangeManager templateRangeManager)
    {
        this.templateRangeManager = templateRangeManager;
    }

    public void setTemplateManager(TemplateManager templateManager)
    {
        this.templateManager = templateManager;
    }

    public void setSpecialityManager(SpecialityManager specialityManager)
    {
        this.specialityManager = specialityManager;
    }

    public void ApplicationManager(ApplicationManager applicationManager)
    {
        this.applicationManager = applicationManager;
    }

    public String getTemplateFileGuid()
    {
        return templateFileGuid;
    }

    public void setTemplateFileGuid(String templateFileGuid)
    {
        this.templateFileGuid = templateFileGuid;
    }

    public Template getTemplate()
    {
        return template;
    }

    public void setTemplate(Template template)
    {
        this.template = template;
    }

    public void setIndicationManager(IndicationManager indicationManager)
    {
        this.indicationManager = indicationManager;
    }

    public String getJsonAllCatalogs()
    {
        return jsonAllCatalogs;
    }

    public void setJsonAllCatalogs(String jsonAllCatalogs)
    {
        this.jsonAllCatalogs = jsonAllCatalogs;
    }

    public CatalogManager getCatalogManager()
    {
        return catalogManager;
    }

    public void setCatalogManager(CatalogManager catalogManager)
    {
        this.catalogManager = catalogManager;
    }

    public IndicationManager getIndicationManager()
    {
        return indicationManager;
    }

    public String getJsonAllIndications()
    {
        return jsonAllIndications;
    }

    public void setJsonAllIndications(String jsonAllIndications)
    {
        this.jsonAllIndications = jsonAllIndications;
    }

    public DbMetaDataManager getDbMetaDataManager()
    {
        return dbMetaDataManager;
    }

    public void setDbMetaDataManager(DbMetaDataManager dbMetaDataManager)
    {
        this.dbMetaDataManager = dbMetaDataManager;
    }

    public String getTableName()
    {
        return tableName;
    }

    public void setTableName(String tableName)
    {
        this.tableName = tableName;
    }

    public String getModalDialogFieldValue()
    {
        return ModalDialogFieldValue;
    }

    public void setModalDialogFieldValue(String modalDialogFieldValue)
    {
        ModalDialogFieldValue = modalDialogFieldValue;
    }

    public String getDeletedFormulaGuid()
    {
        return deletedFormulaGuid;
    }

    public void setDeletedFormulaGuid(String deletedFormulaGuid)
    {
        this.deletedFormulaGuid = deletedFormulaGuid;
    }

    public ValidationManager getValidationManager()
    {
        return validationManager;
    }

    public void setValidationManager(ValidationManager validationManager)
    {
        this.validationManager = validationManager;
    }

    public String getJsonValidation()
    {
        return jsonValidation;
    }

    public void setJsonValidation(String jsonValidation)
    {
        this.jsonValidation = jsonValidation;
    }

    public String getDeletedValidationGuid()
    {
        return deletedValidationGuid;
    }

    public void setDeletedValidationGuid(String deletedValidationGuid)
    {
        this.deletedValidationGuid = deletedValidationGuid;
    }

    public HashMap getDynaBean()
    {
        return dynaBean;
    }

    public void setDynaBean(HashMap dynaBean)
    {
        this.dynaBean = dynaBean;
    }

    public AbstractFormulaGenerator getServerFormulaGenerator()
    {
        return serverFormulaGenerator;
    }

    public void setServerFormulaGenerator(AbstractFormulaGenerator serverFormulaGenerator)
    {
        this.serverFormulaGenerator = serverFormulaGenerator;
    }

    public FileCreator getFileCreator()
    {
        return fileCreator;
    }

    public void setFileCreator(FileCreator fileCreator)
    {
        this.fileCreator = fileCreator;
    }

    public String getApplicationGuid()
    {
        return applicationGuid;
    }

    public void setApplicationGuid(String applicationGuid)
    {
        this.applicationGuid = applicationGuid;
    }

    public String getApplicationName()
    {
        return applicationName;
    }

    public void setApplicationName(String applicationName)
    {
        this.applicationName = applicationName;
    }

    public TemplateDependenceManager getTemplateDependenceManager()
    {
        return templateDependenceManager;
    }

    public void setTemplateDependenceManager(TemplateDependenceManager templateDependenceManager)
    {
        this.templateDependenceManager = templateDependenceManager;
    }

    public String getUserDefinedJs()
    {
        return userDefinedJs;
    }

    public void setUserDefinedJs(String userDefinedJs)
    {
        this.userDefinedJs = userDefinedJs;
    }

    public ValidatorManager getValidatorManager()
    {
        return validatorManager;
    }

    public void setValidatorManager(ValidatorManager validatorManager)
    {
        this.validatorManager = validatorManager;
    }

    public DynaBeanManager getDynaBeanManager()
    {
        return dynaBeanManager;
    }

    public void setDynaBeanManager(DynaBeanManager dynaBeanManager)
    {
        this.dynaBeanManager = dynaBeanManager;
    }

    public ComboDefineManager getComboDefineManager()
    {
        return comboDefineManager;
    }

    public void setComboDefineManager(ComboDefineManager comboDefineManager)
    {
        this.comboDefineManager = comboDefineManager;
    }

    private static final long serialVersionUID = -6930208653794376921L;
    private Template template;
    private TemplateManager templateManager;
    private TemplateDependenceManager templateDependenceManager;
    private SpecialityManager specialityManager;
    private TemplateFileManager templateFileManager;
    private TemplateIndicationManager templateIndicationManager;
    private TemplateRangeManager templateRangeManager;
    private ApplicationManager applicationManager;
    private DbMetaDataManager dbMetaDataManager;
    private ReportPeriodTypeManager reportPeriodTypeManager;
    private FormulaManager formulaManager;
    private IndicationManager indicationManager;
    private CatalogManager catalogManager;
    private ValidationManager validationManager;
    private ValidatorManager validatorManager;
    private DynaBeanManager dynaBeanManager;
    private ComboDefineManager comboDefineManager;
    private FileCreator fileCreator;
    private AbstractFormulaGenerator serverFormulaGenerator;
    private HashMap dynaBean;
    private String templateFileGuid;
    private File templateExcel;
    private InputStream excelInputStream;
    private int contentLength;
    private String templateExcelFileName;
    private String templateExcelContentType;
    private String jsonIndication;
    private String jsonRange;
    private String jsonFormula;
    private String jsonValidation;
    private String jsonApplication;
    private String jsonReportPeriodType;
    private String deletedIndicationGuid;
    private String deletedRangeGuid;
    private String deletedFormulaGuid;
    private String deletedValidationGuid;
    private String jsonAllIndications;
    private String jsonAllCatalogs;
    private String tableName;
    private String applicationGuid;
    private String applicationName;
    private String ModalDialogFieldValue;
    private String userDefinedJs;

}
